package dhy.lyb.change.controller;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 训练操作控制器
 * Created by Administrator on 2016/11/25.
 */
@Controller
@Scope("prototype")
public class ActivityInsController extends BaseController {

    /**
     * 文件下载接口
     *
     * @param fileName
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "activity/download/{fileName}")
    @ResponseBody
    public String download(@PathVariable("fileName") String fileName,
                           HttpServletRequest request,
                           HttpServletResponse response) {

        fileName = fileName + ".zip";
        super.downloadFile(fileName, "activity", request, response);
        //  返回值要注意，要不然就出现下面这句错误！
        //java+getOutputStream() has already been called for this response
        return null;
    }
}
